package com.qcs.sleep.call;

import android.content.Context;

import java.util.Observer;

/**
 * Created by chshqiang on 15-7-21.
 * CallChanger工具类
 */
public class CallTools {

    public static void sendAction(String action) {
        ActionChanger.getInstance().send(action);
    }

    public static void sendTime(Context context) {
        TimeChanger.getInstance().send();
        AppChanger.getInstance().send(context);
    }

    public static void sendPush(String push) {
        PushChanger.getInstance().send(push);
    }

    public static void addWatcher(Observer watcher) {
        if (watcher instanceof TimeWatcher) {
            TimeChanger.getInstance().addObserver(watcher);
        } else if (watcher instanceof PushWatcher) {
            PushChanger.getInstance().addObserver(watcher);
        } else if (watcher instanceof ActionWatcher) {
            ActionChanger.getInstance().addObserver(watcher);
        } else if (watcher instanceof AppWatcher) {
            AppChanger.getInstance().addObserver(watcher);
        }
    }

    public static void removeWatcher(Observer watcher) {
        if (watcher instanceof TimeWatcher) {
            TimeChanger.getInstance().deleteObserver(watcher);
        } else if (watcher instanceof PushWatcher) {
            PushChanger.getInstance().deleteObserver(watcher);
        } else if (watcher instanceof ActionWatcher) {
            ActionChanger.getInstance().deleteObserver(watcher);
        } else if (watcher instanceof AppWatcher) {
            AppChanger.getInstance().deleteObserver(watcher);
        }
    }

    public static void removeWatchers() {
        PushChanger.getInstance().deleteObservers();
        ActionChanger.getInstance().deleteObservers();
        AppChanger.getInstance().deleteObservers();
        TimeChanger.getInstance().deleteObservers();
    }
}
